<?PHP
	require 'includes/master.inc.php';
	$auth->admin();
	
	$f = new Feedback($_GET['id']);
	if($f->id == '') redirect('feedback.php');

	if(isset($_POST['btnnew']))
	{
		$f->new = 1;
		$f->update();
		redirect('feedback.php');
	}
	elseif(isset($_POST['btndelete']))
	{
		$f->deleted = 1;
		$f->new = 0;
		$f->update();
		redirect('feedback.php');
	}
	else
	{
		$f->new = 0;
		$f->update();
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>Feedback | Appcaster</title>
	<?PHP include 'inc/meta.inc.php'; ?>
</head>

<body id="home">
	<?PHP include 'inc/head.inc.php'; ?>
	<div id="nav">
		<ul>
			<li><a href='<?PHP WEBROOT();?>'>Applications</a></li>
			<li><a href='<?PHP WEBROOT();?>orders.php'>Orders</a></li>
			<li class='selected'><a href='<?PHP WEBROOT();?>feedback.php'>Feedback (<?PHP echo Feedback::newCountTotal();?>)</a></li>
			<li><a href='<?PHP WEBROOT();?>stats.php'>Stats</a></li>
			<li><a href='<?PHP WEBROOT();?>options.php'>Options</a></li>
		</ul>
	</div>

	<div id="menutabs">
		<ul id="tabnav">
			<li><a href="feedback.php">All Feedback</a></li>
			<li><a href="feedback.php?type=support">Support Questions</a></li>
			<li><a href="feedback.php?type=bug">Bug Reports</a></li>
			<li><a href="feedback.php?type=feature">Feature Requests</a></li>
			<li class="selected"><a href="view-feedback.php?id=<?PHP echo $f->id;?>">Feedback #<?PHP echo $f->id;?></a></li>
		</ul>
	</div>

	<div id="contain">
		<table>
			<tr>
				<th class="r">App Name</th>
				<td><?PHP echo $f->appname . ' ' . $f->appversion;?></td>
			</tr>
			<tr>
				<th class="r">System</th>
				<td><?PHP echo $f->systemversion;?></td>
			</tr>
			<tr>
				<th class="r">Email</th>
				<td>
					<a href="mailto:<?PHP echo $f->email;?>"><?PHP echo $f->email;?></a>
					<?PHP echo ($f->reply == 1) ? "(Wants a reply)" : "(Does not want a reply)"; ?>
				</td>
			</tr>
			<tr>
				<th class="r">Type</th>
				<td><?PHP echo ucwords($f->type);?></td>
			</tr>
			<tr>
				<th class="r">Message</th>
				<td><?PHP echo nl2br($f->__message);?></td>
			</tr>
			<?PHP if($f->type == "feature") : ?>
			<tr>
				<th class="r">Importance</th>
				<td><?PHP echo $f->importance;?></td>
			</tr>
			<?PHP endif; ?>
			<?PHP if($f->type == "bug") : ?>
			<tr>
				<th class="r">Critical</th>
				<td><?PHP echo ($f->critical == 0) ? "No" : "Yes!"; ?></td>
			</tr>
			<?PHP endif; ?>
			<tr>
				<th class="r">Date Submitted</th>
				<td><?PHP echo dater('n/j/Y g:ia', $f->dt); ?></td>
			</tr>
			<tr>
				<th class="r">IP</th>
				<td><?PHP echo $f->ip;?></td>
			</tr>
		</table>
		
		<form action="view-feedback.php?id=<?PHP echo $f->id;?>" method="post">
			<p>
				<input type="submit" name="btnnew" value="Mark as New" id="btnnew"/>
				<input type="submit" name="btndelete" value="Delete" id="btndelete"/>
			</p>
		</form>					
		
	</div>
</body>
</html>